stop! // to prevent mistakingly running everything

					*************************************
					* 			Main Analysis			*
					*************************************
/* 
 
 File Description: this file generates the figures and tables in the main body of the article.
 
 Data file inputs: 
 
 *confed_2023data.dta
 *CCES_full_zip.dta
 *CCES_full_county.dta
 *VSG_full_zip.dta
 *VSG_full_county.dta
 *FBI_full_county.dta
 *FBI_white_offender_county.dta
 *FBI_full_zip.dta
 *FBI_white_offender_zip.dta
 
 Outputs in draft: 
 
 *Table 1: Active and Removed Symbols, by Debate Status (2014-2017)
 *Figure 2: Test for Common Trend Assumption
 *Table 2: Effect of Removals for Nov 2014 vs Dec 2015 (CCES)
 *Table 3: Effect of Removals for Dec 2016 vs July 2017 (VSG)
 *Table 4: Effect of Removals on Hate Crimes for 2014 vs 2015 (FBI)
 
 Names of output files:

 *figures/figure-2-main.pdf
 *table 2 output files
	*tables/table2-panelB-county.txt
	*tables/table2-panelA-zipcode.txt
 *tables/table3.txt
 *table 4 output files
	*tables/table4-panelA-county.txt
	*tables/table4-panelB-zipcode.txt
 
*/

* change to your personal directory

	global main "/Users/replication_package"

* preliminaries

	set more off
	set matsize 10000	
	

*****************************************************************************
* CODE FOR TABLE 1: Active and Removed Symbols, by Debate Status (2014-2017)
*****************************************************************************

	use "$main/data/confed_2023data.dta", clear

	ta some_debate symbolstatus if inrange(Year_Removed, 2014, 2017) | Year_Removed==.

/* Output in Table 1; created Table manually in Latex

some_debate|     symbolstatus
		   |    active    removed |     Total
-----------+----------------------+----------
         0 |     1,633          8 |     1,641 
         1 |        75         80 |       155 
-----------+----------------------+----------
     Total |     1,708         88 |     1,796 


*/

*************************************************************
* CODE FOR FIGURE 2: Placebo Test for Common Trend Assumption
*************************************************************

	*Note: some manual formatting was done to the figure to create labels, but code replicates output without the manual labeling

**********************
* At zip code level *
*********************
	
	** PARALLEL TRENDS  **
	
	* 2010 [pre] - 2012 [post]
	
	use "$main/data/CCES_full_zip.dta", clear
	drop if year>2015
	drop if year == 2011 | year == 2013
	
	*subset sample to zipcodes where no removal prior to 2014m11; e.g. zipcodes treatable between 2014-2015
	bysort zip: egen pre_event_removals = count(Unique_ID) if monthly_date_confed < tm(2014m11)
	drop if pre_event_removals!=. 
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
		
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)
	
	gen byte pre_post= 0 if monthly_date_cces==tm(2010m11)
	replace pre_post=1 if  monthly_date_cces==tm(2012m11)
	drop if pre_post==. 

	gen did = pre_post*treated 
		
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm DemVote12 logpop percent_black percent_white med_hh_income percent_college, by(zip state region year countycode pre_post treated did)
	
	xtset zip year  
	*need to interact covariates with post-treatment indicator
		gen black_post = percent_black*pre_post
		gen white_post = percent_white*pre_post
		gen college_post = percent_college*pre_post
		gen income_post = med_hh_income*pre_post
		gen pop_post = logpop*pre_post
		
	quietly eststo A: reghdfe symbolic_index i.treated##i.pre_post black_post white_post pop_post college_post income_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo B: reghdfe affirm i.treated##i.pre_post black_post white_post pop_post college_post income_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)

	* 2012 [pre] - 2014 [post]

	use "$main/data/CCES_full_zip.dta", clear
	drop if year>2015
	drop if year == 2011 | year == 2013
	
	*subset sample to zipcodes where no removal prior to 2014m11; e.g. zipcodes treatable between 2014-2015
	bysort zip: egen pre_event_removals = count(Unique_ID) if monthly_date_confed < tm(2014m11)
	drop if pre_event_removals!=. 
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
		
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	gen byte pre_post= 0 if monthly_date_cces==tm(2012m11)
	replace pre_post=1 if  monthly_date_cces==tm(2014m11)
	drop if pre_post==. 

	gen did = pre_post*treated 
		
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm DemVote12 logpop percent_black percent_white med_hh_income percent_college, by(zip state region year countycode pre_post treated did)
		
	xtset zip year  
	
	*need to interact covariates with post-treatment indicator
		gen black_post = percent_black*pre_post
		gen white_post = percent_white*pre_post
		gen college_post = percent_college*pre_post
		gen income_post = med_hh_income*pre_post
		gen pop_post = logpop*pre_post
		
	quietly eststo C: reghdfe symbolic_index i.treated##i.pre_post black_post white_post pop_post college_post income_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo D: reghdfe affirm i.treated##i.pre_post black_post white_post pop_post college_post income_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)

	* 2014 [pre] - 2015 [post]
	* the regression of interest
	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
		
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

		drop if monthly_date_confed<=tm(2014m2)
		gen did = pre_post*treated 
		
		gen logpop = log(pop2010) 		
		collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)

	xtset zip year 
	
	*need to interact covariates with post-treatment indicator
		gen black_post = percent_black*pre_post
		gen white_post = percent_white*pre_post
		gen college_post = percent_college*pre_post
		gen income_post = med_hh_income*pre_post
		gen pop_post = logpop*pre_post
		
	quietly eststo E: reghdfe symbolic_index i.treated##i.pre_post  black_post white_post pop_post college_post income_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo F: reghdfe affirm i.treated##i.pre_post  black_post white_post pop_post college_post income_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)

	*figure 4
	#delimit;
	coefplot (A, msymbol(D) mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(B, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(C, msymbol(D)  mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(D, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(E, msymbol(D)  mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(F, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)), keep(1.treated#1.pre_post)
	legend(order(1 "racial resentment" 3 "affirmative action") ring(0) position(11) bmargin(large) size(vsmall) col(2)) mlabposition(1)
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", ""))))
	vertical drop(1.treated 1.pre_post _cons) yline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white))
	ytitle("Difference-in-Differences Coefficients" " ")
	title("", size(small) color(black))
	lcol(black)
	ylab(-.8(0.2).8, nogrid) xlabel("");
	#delimit cr
	graph export "$main/figures/figure-2-main.pdf", replace
	
	*some manual formatting done to figure in Stata Edit - specifically added the labels on the X-axis and the dividing line for pre-post

***************************************************************
* CODE FOR TABLE 2: Effect of Removals for Nov 2014 vs Dec 2015
***************************************************************

* Load data

  use "$main/data/CCES_full_county.dta", clear

	********************************************
	* 		DATA PREP: 2014-2015 DiD 
	********************************************

	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015	
	
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	*egen totalmon = total(tag) if inrange(monthly_date_confed, tm(2015m7), tm(2015m11)), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	*none with zero monuments at the start of June 2015 so don't drop any counties from sammple

		*only depends on time
		gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
		
		*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
		*control group: monuments still active after December 2015
		
		bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
		by countycode: egen treated = max(removed)
		
		drop if monthly_date_confed<=tm(2014m2)
		gen did = pre_post*treated 
		
		gen logpop = log(pop2010) 
		
		collapse symbolic_index affirm religion_important Black_Pop logpop DemVote12, by(state year region countycode pre_post treated did)

		xtset countycode year  
		by countycode, sort: egen obs = count(year)
		drop if obs <2
		drop obs
		
		*need to interact covariates with post-treatment indicator
		gen black_post = Black_Pop*pre_post
		gen Dem_post = DemVote12*pre_post
		gen pop_post = logpop*pre_post

		sum symbolic_index if year==2014, detail
		*0.68 mean, median of 0.67 [dependent variable mean reported in Table 2]
		sum affirm if year==2014, detail
		*0.35 mean, median of 0.33 [dependent variable mean reported in Table 2]

		*generate the interaction term 
		gen treated_prepost = treated*pre_post
		
		********************************************
		* 		REGRESSIONS :  
		********************************************
				
		quietly eststo countyRR1: reghdfe symbolic_index treated pre_post treated_prepost black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
		
		quietly eststo countyRR2: reghdfe symbolic_index treated pre_post treated_prepost black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
		
		quietly eststo countyAA1: reghdfe affirm treated pre_post treated_prepost black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
		
		quietly eststo countyAA2: reghdfe affirm treated pre_post treated_prepost black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)

		esttab countyRR1 countyRR2 countyAA1 countyAA2 using "$main/tables/table2-panelB-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

		*ZIPCODE*
		
		**********************
		* LOAD SURVEY 	 *
		**********************	

		use "$main/data/CCES_full_zip.dta", clear

		********************************************
		* 		DATA PREP: 2014-2015 DiD 
		********************************************
		
		*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
		keep if year == 2014 | year == 2015
			
		egen tag = tag(zip Unique_ID) 
		egen totalmon = total(tag), by(zip)

		ta totalmon if monthly_date_confed<tm(2015m7)
		drop if totalmon==0
		
		*only depends on time
		gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
		
		*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
		*control group: monuments still active after December 2015
		
		bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
		
		*at least ONE of the monuments removed so label all rows with that zipcode as treated 
		by zip: egen treated = max(removed)

		drop if monthly_date_confed<=tm(2014m2)
		gen did = pre_post*treated 
		
		gen logpop = log(pop2010) 
		
		collapse symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
		
		xtset zip year 
		by zip, sort: egen obs = count(year)
		drop if obs <2
		drop obs

		*need to interact covariates with post-treatment indicator
		gen black_post = percent_black*pre_post
		gen white_post = percent_white*pre_post
		gen college_post = percent_college*pre_post
		gen income_post = med_hh_income*pre_post
		gen pop_post = logpop*pre_post

		sum symbolic_index if year==2014, detail
		*0.61 mean, median of 0.63 [dependent variable mean reported in Table 2]
		sum affirm if year==2014, detail
		*0.43 mean, median of 0.43 [dependent variable mean reported in Table 2]

		*generate the interaction term 
		gen treated_prepost = treated*pre_post
	
		********************************************
		* 		REGRESSIONS :  
		********************************************
				
		quietly eststo zipRR1: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
		
		quietly eststo zipRR2: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	
		quietly eststo zipAA1: reghdfe affirm treated pre_post treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
		
		quietly eststo zipAA2: reghdfe affirm treated pre_post treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	
		esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/table2-panelA-zipcode.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

		*please note that tables were manually formatted in Latex with these output
		
***************************************************************
* CODE FOR TABLE 3: Effect of Removals for Dec 2016 vs Dec 2017
***************************************************************		
	
	***************
	* county-level
	***************
	
	*two-period diff-in-diff regression
	
	use "$main/data/VSG_full_county.dta", clear
	keep if year == 2016 | year == 2017
	
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
	
	*treatment period group: monuments removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
	*control group: monuments still active after July 2017

	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2016m12)

	gen did = pre_post*treated 

	collapse ft_blacks age race liberal conserv educ male, by(id state countycode year pre_post treated did)
	
	gen age2 = age*age
	
	xtset id year
	
	sum ft_blacks if year==2016, detail
	*mean 0.72, median 0.77 [mean reported in Table 3]
	
	unique countycode 
	*396

	*generate the interaction term 
	gen treated_prepost = treated*pre_post
		
		********************************************
		* 		REGRESSIONS :  
		********************************************

		quietly eststo countyFT1: reghdfe ft_blacks treated_prepost age age2 race liberal educ male liberal conserv, vce(cluster countycode) absorb(i.id i.year)
		
		quietly eststo countyFT2: reghdfe ft_blacks treated_prepost age age2 race liberal educ male liberal conserv i.state##c.year, vce(cluster countycode) absorb(i.id)
		
	****************
	* zipcode-level 
	****************
	
	use "$main/data/VSG_full_zip.dta", clear
	keep if year == 2016 | year == 2017
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	
	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
	
	*treatment period group: monuments removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
	*control group: monuments still active after July 2017
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2016m12) 

	gen did = pre_post*treated 
	
	collapse ft_blacks age race liberal conserv educ male, by(id zip state countycode year pre_post treated did)

	gen age2 = age*age

	xtset id year  
	
	sum ft_blacks if year==2016, detail
	*mean 0.72, median 0.78 [mean reported in Table 3]
	
	unique zip
	*294

	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
		********************************************
		* 		REGRESSIONS :  
		********************************************

		quietly eststo zipFT1: reghdfe ft_blacks treated_prepost age age2 race liberal conserv educ male, vce(cluster zip) absorb(i.id i.year)
		
		quietly eststo zipFT2: reghdfe ft_blacks treated_prepost age age2 race liberal conserv educ male i.state##c.year, vce(cluster zip) absorb(i.id i.year)
		
		esttab zipFT1 zipFT2 countyFT1 countyFT2 using "$main/tables/table3.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

		*please note that tables were manually formatted in Latex with these output

****************************************************************************
* CODE FOR TABLE 4: Effect of Removals on Hate Crimes for 2014 vs 2015 (FBI)
****************************************************************************
     
	******************************
	* County-level; All offenders  
	******************************

	use "$main/data/FBI_full_county.dta", clear

	keep if year==2014 | year==2015 
	
	*only keep counties that had at least one monument at the start of Jan 2015
		
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*none with zero monuments at the start of Jan 2015 so don't drop any counties from sammple
	
	*create treatment and control groups

	by countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by countycode: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12))
	
	gen did = pre_post*treated 

	collapse total_hc_pc Black_Pop CENSUS2010POP DemVote12, by(ADDRESS_STATE year REGION countycode treated pre_post did)
	
	xtset countycode year  

	gen logpop = log(CENSUS2010POP)
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	encode ADDRESS_STATE, gen(state)
	ren REGION region
	
	summarize total_hc_pc if year==2014, detail
	*mean 1.82, median 0.99 [mean of dependent variable reported in Table 4]
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*regressions

	quietly eststo countyHC1: reghdfe total_hc_pc treated_prepost black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
				
	quietly eststo countyHC2: reghdfe total_hc_pc treated_prepost black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	
	*******************************
	* County-level; White offenders  
	*******************************

	use "$main/data/FBI_white_offender_county.dta", clear

	keep if year==2014 | year==2015 
  
	*only keep counties that had at least one monument at the start of Jan 2015
		
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*none with zero monuments at the start of Jan 2015 so don't drop any counties from sammple
	
	*create treatment and control groups

	by countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by countycode: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12))
	
	gen did = pre_post*treated 

	collapse total_hc_pc Black_Pop CENSUS2010POP DemVote12, by(ADDRESS_STATE year REGION countycode treated pre_post did)
	
	xtset countycode year  

	gen logpop = log(CENSUS2010POP)
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	encode ADDRESS_STATE, gen(state)
	ren REGION region
	
	summarize total_hc_pc if year==2014, detail
	*mean 1.34, median 0.71 [mean of dependent variable reported in Table 3]
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*regressions

	quietly eststo countyHCW1: reghdfe total_hc_pc treated_prepost black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
				
	quietly eststo countyHCW2: reghdfe total_hc_pc treated_prepost black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	
	esttab countyHC1 countyHC2 countyHCW1 countyHCW2 using "$main/tables/table4-panelA-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

	******************************
	* Zipcode-level; All offenders  
	******************************

	use "$main/data/FBI_full_zip.dta", clear
	keep if year==2014 | year==2015 

	*only keep zipcodes that had at least one monument at the start of Jan 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*none with zero monuments at the start of Jan 2015 so don't drop any zipcode from sammple
	
	*create treatment and control groups
	
	by zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by zip: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12)) 
		
	gen did = pre_post*treated 

	gen logpop = log(pop2010)
	collapse total_hc_pc percent_black percent_college med_hh_income percent_white logpop, by(zip ADDRESS_STATE year pre_post treated did)
	
	xtset zip year 

	*need to interact covariates with post-treatment indicator
		gen black_post = percent_black*pre_post
		gen white_post = percent_white*pre_post
		gen college_post = percent_college*pre_post
		gen income_post = med_hh_income*pre_post
		gen pop_post = logpop*pre_post

	encode ADDRESS_STATE, gen(state)
	
	summarize total_hc_pc if year==2014, detail
	*mean 20.3, median 6 [mean of dependent variable reported in Table 4]

	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*regressions

	quietly eststo zipHC1: reghdfe total_hc_pc treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
						
	quietly eststo zipHC2: reghdfe total_hc_pc treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	
	********************************
	* Zipcode-level; White offenders  
	********************************	

	use "$main/data/FBI_white_offender_zip.dta", clear
	keep if year==2014 | year==2015 

	*only keep zipcodes that had at least one monument at the start of Jan 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*none with zero monuments at the start of Jan 2015 so don't drop any zipcode from sammple
	
	*create treatment and control groups
	
	by zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by zip: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12)) 
		
	gen did = pre_post*treated 

	gen logpop = log(pop2010)
	collapse total_hc_pc percent_black percent_college med_hh_income percent_white logpop, by(zip ADDRESS_STATE year pre_post treated did)
	
	xtset zip year 

	*need to interact covariates with post-treatment indicator
		gen black_post = percent_black*pre_post
		gen white_post = percent_white*pre_post
		gen college_post = percent_college*pre_post
		gen income_post = med_hh_income*pre_post
		gen pop_post = logpop*pre_post

	encode ADDRESS_STATE, gen(state)
	
	summarize total_hc_pc if year==2014, detail
	*mean 14.9, median 4.88 [mean of dependent variable reported in Table 4]
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*regressions

	quietly eststo zipHCW1: reghdfe total_hc_pc treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
						
	quietly eststo zipHCW2: reghdfe total_hc_pc treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)

	esttab zipHC1 zipHC2 zipHCW1 zipHCW2 using "$main/tables/table4-panelB-zipcode.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

	*please note that tables were manually formatted in Latex with these output
